<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
<style type="text/css">
.user-head {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 5px;
}
</style>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>个人中心<span>&gt;</span>工作日志列表
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>
	
	<div class="row">
		<div class="col-sm-12">
		<!-- 标签1 start -->
		    	<div id="tab-1" class="tab-pane active">
		    	<div class="panel-body">
		    	<!-- 标签1内容 start -->
			<div class="ibox-content">
			<!-- 搜索框部分start -->
			<p:btn value="serch">
				<form class="form-inline" id="serchform">
				<%-- <label for="exampleInputName2">项目名称</label>
				<div class="form-group mr-18">
				<div class="col-sm-2 ">
								 <select name="projId" class=" select2 form-control autoFull"
										style="width: 200px" 
										data-url="${path}/admin/WorkLogAction/showProject" 
										data-filed="projName"
										data-value="id">
										<option value="">请选择工程项目</option>
									</select>
							</div>
				</div> --%>
				
					<label for="exampleInputName2">创建人</label>
					<div class="form-group mr-18">
							<div class="col-sm-2 ">
								 <select name="userId" class=" select2 form-control autoFull"
										style="width: 200px" 
										data-url="${path}/admin/WorkLogAction/selectMentor" 
										data-filed="name"
										data-value="id">
										<option value="">请选择创建人</option>
									</select>
							</div>
					</div>
					<div class="form-group mr-18">
					<label class="col-sm-2 control-label">创建日期</label> <input
						name="beginTime" type="text" placeholder="开始时间"
						class="form-control datetimepicker" id="beginTime"> <input
						placeholder="结束时间" name="endTime" type="text"
						class="form-control datetimepicker" id="endTime">
					</div>
					<button  onclick="myGrid.serchData()" type="button" class="btn btn-info btn-sm"><i class="fa fa-search " ></i> 搜索</button>
					<button  type="button" onclick="MForm.reset('#serchform');" class="btn btn-info btn-sm"><i class="fa fa-refresh " ></i> 重置</button>
				</form>
				</p:btn>
			<!-- 搜索框部分en -->
				<!-- <div class="option-bar" >
					<button onclick="openAdd()" type="button" class="btn btn-success btn-sm"><i class="fa fa-plus" ></i>新增</button>
				</div> -->
				<table id="mgrid" class="table table-no-bordered table-striped">
					<thead>
						<tr>
							<th data-checkbox="true"  ></th>
							<th data-formatter="MGrid.indexfn" data-align="center"  data-width="30px" >序号</th>
							<th data-field="projName" data-formatter="createTitle">服务项目</th>
							<th data-field="status" data-formatter="changeStatusStyle">项目状态</th>
							<th data-field="workingHours" data-formatter="changeStatusStyle1">服务时长</th>
							<th data-field="workContent" data-width="500px">服务内容</th>
							<th data-field="senderName">创建人</th>
							<!-- <th data-align="center"  data-width="150px" data-field="workLogId" data-formatter="buidOperate">操作</th> -->
						</tr>
					</thead>
				</table>
				</div>
            <!-- 标签1内容 end -->        
			</div>
           </div>
             
           
     
	</div>
	</div>

<script type="text/javascript">
	$(".select2").select2();
	var myGrid;
	var myGrid2;
		$(function(){
			MTools.autoFullSelect();
			//有删除权限
			var delUrl="";
			<p:btn value="dels">
			delUrl="${path}/admin/project/del";
			</p:btn>
			
			//初始化表格1我发送的工作日志
			 myGrid=MGrid.initGrid({
				 url:"${path}/admin/WorkLogAction/selectAllUserWork",
				 delUrl:delUrl,
				 tableSelecter:"#mgrid"
			 });
			
			 var _initParam = {
						format : 'yyyy-mm-dd',
						todayBtn : false,
						autoclose : true,
						startView : 2,
						maxView : 2,
						minView : 2,
						endDate: new Date()
					};
					MTools.ininDatetimepicker(_initParam);
					//限制结束时间不小于开始时间
					var initParam = {
						format : 'yyyy-mm-dd',
						todayBtn : false,
						autoclose : true,
						startView : 2,
						maxView : 2,
						minView : 2,
						endDate: new Date()
					};
					MTools.limitStartEndTime(initParam);
			
		})
		
			
		
		function buidOperate(value, row, index){
			var html=[]
			html[0]='<button class="btn btn-default btn-sm mr-5" onClick="openEdit('+value+')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			
			return html;
		}
		
		//改变状态样式		
		function changeStatusStyle(value, row, index){
			var html='<div class="project-status"><span class="label label-primary">'+value+'</span></div>';
			return html;
		}
		
		function changeStatusStyle1(value, row, index){
			console.log(value);
			var html1='<div class="project-status"><span class="label label-primary">'+value+'小时</span></div>';
			return html1;
		}
		//创建项目名称
		function createTitle(value, row, index){
			var html= "";
			html +='<div class="text-warning"><h2><strong>'+value+'</strong></h2></div>';
			html +='<div><small>创建日志时间&nbsp;:&nbsp;'+MTools.farmterTime(row.createTime)+'</small></div>';
			
			return html;
		}
		
		//创建头像
		function createImg(value, row, index){
			var projUserList = value;
			var html = "";
			for(var i = 0;i<projUserList.length;i++){
				var imgUrl = projUserList[i].userPhoto;
				var uname = projUserList[i].userName;
				html +='<img title="'+uname+'" class="user-head" src="'+imgUrl+'">';
			}
			return html;
		}
		
		
		//创建项目名进度
		function createProgress(value, row, index){
			var html= "";
			var createDate = row.createTime;//创建时间			
			var endDate = row.endTime;//预计结束时间
			var nowDate=new Date().getTime();//当前时间	
			var p=((nowDate - createDate)/(endDate - createDate)) *100;
			p = p>100?100:p.toFixed(2);	
			if((endDate - createDate)<0){
				p = 100
			}
			html +='<small>当前开发进度：'+p+'%</small><div class="progress progress-mini">'
                +'<div style="width: '+p+'%" class="progress-bar"></div></div><br>';
            var projId = row.id;
            var taskNum = row.taskNum;
            var taskFinishNum = row.taskFinishNum;
            var projStatus = 0;
            if(taskNum!=null && taskFinishNum){
            	projStatus = (taskFinishNum / taskNum)*100;
            }          
            html +='<small>当前任务完成进度：'+projStatus.toFixed(2)+'%</small><div class="progress progress-mini">'
            +'<div style="width: '+projStatus.toFixed(2)+'%" class="progress-bar"></div></div>';
            return html;
		}
		
		//查询任务，不包括已取消的,已删除的
		function queryTaskAll(projId){
			var projTaskAll = 0;
			$.AjaxProxy({
				a : false,
				c : false
			}).invoke(
				"${path}/admin/project/queryAllTask?projId="+projId,
				function(loj) {
					var total = loj.attr("result").total;
					if(total!=null){
						projTaskAll = total;
					}
				});
			return projTaskAll;
		}
		
		//查询完成任务，不包括已取消的,已删除的
		function queryTaskFinishAll(projId){
			var projFinishTaskAll = 0;
			$.AjaxProxy({
				a : false,
				c : false
			}).invoke(
				"${path}/admin/project/queryAllFinishTask?projId="+projId,
				function(loj){
					var total = loj.attr("result").total;
					if(total!=null){
						projFinishTaskAll = total;
					}
				});
			return projFinishTaskAll;
		}
		
		//打开添加界面
		/* <p:btn value="add">
		function openAdd() {
			layer.full(
			layer.open({
				type : 2,
				title : "添加项目",
				area : [ MUI.SIZE_L, '400px' ],
				content : [ '${path}/admin/WorkLogAction/editForm']
			})); 
		}
		</p:btn> */
		
		function openAdd() {
			layer.open({
				type : 2,
				title : "添加工作日志",
				area : [ MUI.SIZE_L, '400px' ],
				content : [ '${path}/admin/WorkLogAction/addForm']
			}); 
		}
		//打开添加界面
		<p:btn value="edit">
		function openEdit(value) {
			layer.open({
				type : 2,
				title : "修改日志",
				area : [ MUI.SIZE_L,'400px'],
				content : [ '${path}/admin/WorkLogAction/editForm?workLogId='+value]
			}); 
		}
		</p:btn>
		function openShow(value) {
			layer.open({
				type : 2,
				title : "显示",
				area : [ MUI.SIZE_L,'400px'],
				content : [ '${path}/admin/WorkLogAction/show?workLogId='+value]
			}); 
		}

	</script>
	</body>
</html>
